import request from '@/utils/request'

export function login(username, password, authCode) {
    return request({
        url: '/sso/login',
        method: 'post',
        data: {
            username,
            password,
            authCode
        }
    })
}

export function getAuthCode(username) {
    return request({
        url: '/sso/authCode',
        method: 'get',
        params: {
            'username': username
        }
    })
}

export function register(username, password, nickname, authCode) {
    return request({
        url: '/sso/register',
        method: 'post',
        data: {
            username,
            password,
            nickname,
            authCode
        }
    })
}

export function isUsernameExist(username) {
    return request({
        url: '/sso/is-username-exist',
        method: 'get',
        params: {
            'username': username,
        }
    })
}

export function isNicknameExist(nickname) {
    return request({
        url: '/sso/is-nickname-exist',
        method: 'get',
        params: {
            'nickname': nickname,
        }
    })
}

export function isLogin() {
    return request({
        url: '/sso/is-login',
        method: 'get',
    })
}